package com.djk;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

import java.util.List;

public class SearchResultActivity extends AppCompatActivity {
    ListView resultList;
    WordDao wordDao;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_result);

        wordDao = new WordDao(SearchResultActivity.this);
        resultList = findViewById(R.id.lv_search_result);

        //接收传过来的单词
        Intent intent = getIntent();
        if(intent!=null){
            String searchWord = intent.getStringExtra("searchWord");
            //在数据库中查找搜索的单词（模糊查询）
            List<Word> words = wordDao.searchWords(searchWord);
            SearchResultAdapter adapter = new SearchResultAdapter(SearchResultActivity.this, words);
            resultList.setAdapter(adapter);
        }
    }
}